<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>question</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/renting/css/public.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/renting/css/header.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/renting/css/bottom.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/renting/css/ask.css">
</head>
<body>
<!-- 头部 -->
<div class="header">
    <div class="nav">
        <a href="${pageContext.request.contextPath}/renting/index.jsp" class="nav_title">好客租房</a>
        <ul class="nav_ul">
            <li><a href="${pageContext.request.contextPath}/renting/index.jsp">首页</a></li>
            <li><a href="${pageContext.request.contextPath}/renting/pages/onther/Findroom.jsp" style="color: #2983C9;">轻松找房</a></li>
            <li><a href="${pageContext.request.contextPath}/renting/pages/onther/entry.jsp">房东入驻</a></li>
            <li><a href="${pageContext.request.contextPath}/renting/pages/onther/chat_news.jsp">消息</a></li>
            <li><a href="${pageContext.request.contextPath}/renting/pages/onther/login.jsp">登录</a></li>
        </ul>
        <img src="${pageContext.request.contextPath}/renting/img/icon/lianxi-1.png" class="nav_img">
        <p class="nav_phone">
            <span>13301131116</span>
            <span>13301131116</span>
        </p>
    </div>
</div>

<div class="main">
    <div class="main-title">
        <div class="answer active">我的回答</div>
        <div class="record">回答记录</div>
    </div>
    <!-- 问题区域 -->
    <div class="main-content">
        <div class="problem">
            <div class="problem-title">
                <div class="problem-icon"> 问 </div>
                <div class="problem-text">
                    [${communityName}]${content}？
                </div>
                <div class="problem-time"  id="tim">
                    ${tim}
                </div>
            </div>
            <div class="text">
                <textarea id="text" placeholder="热心肠的你帮TA回答一下吧~~"></textarea>
                <div class="submit">
                    <button type="button" onclick="faClick()">发布</button>
                    <script>
                      function faClick(){
                          var data ={"questionId":${rid},"userId":${sessionScope.drom1},"content":$("#text").val()}
                          console.log(data);
                          $.ajax({
                              url:"${pageContext.request.contextPath}/question/addQuestionDetails",// 请求路劲
                              type:"post",
                              data:{"data":JSON.stringify(data)},
                              success:function (data){
                                  if(data=="OK"){
                                      window.location.reload();
                                  }else{
                                      alert("您还为登录！！")
                                  }

                              }
                          })
                      }
                    </script>
                </div>
            </div>
        </div>
    </div>

    <!-- 回答区域 -->
    <div class="main-content content-list">
        <div class="problem">
            <div class="problem-title">
                <div class="problem-icon"> 答 </div>
            </div>
        </div>

        <div class="list">
            <c:forEach items="${Question}" var="u">
              <span  class="item">
                <div class="left">${communityName}：${u.content}</div>
                <div class="right">${u.answerTime}</div>
              </span>
            </c:forEach>
        </div>
    </div>

</div>

<div class="bottom">
    <p>沪公网安备 31011402005354号</p>
</div>
</body>
</html>
<script src="${pageContext.request.contextPath}/renting/js/jQuery-3.4.1.js"></script>
<script src="${pageContext.request.contextPath}/renting/js/header.js"></script>
<script type="text/javascript">
    var login=sessionStorage.getItem("login");
    var url="";
    if(login==1){
        url="${pageContext.request.contextPath}/renting/pages/tenant/inspection.jsp";
    }
    if(login==2){
        url="${pageContext.request.contextPath}/renting/pages/landlord/release.jsp";
    }
    judge_login(url,"${pageContext.request.contextPath}/renting/pages/onther/login.jsp");
</script>